The following problems appeared in the exercises in the coursera course Image Processing (by NorthWestern University). The following descriptions of the problems are taken directly from the assignment's description.
#ipython nbconvert pcaiso.ipynb
%matplotlib inline
from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Click here to toggle on/off the raw code."></form>''')
The next figure shows the problem statement. Although it was originally implemented in MATLAB, in this article a python implementation is going to be described.
from IPython.display import Image
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\ex1.png', width=800)
The following figure shows how the images get more and more blurred after the application of the nxn LPF as n increases.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\im1.png')
The following figure shows how the quality of the transformed image decreases when compared to the original image, when an nxn LPF is applied and how the quality (measured in terms of PSNR) degrades as n (LPF kernel width) increases.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\im2.png')
The following figure describes the problem:
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\ex2.png', width=800)
The following steps are needed to be followed:
Although in the original implementation MATLAB was used, but the following results come from a python implementation.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\sampling3.png', width=800)
As we go on increasing the kernel size, the quality fo the final image obtained by down/up sampling the original image decreases as n increases, as shown in the following figure.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\im3.png')
The following figure describes the problem:
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\ex3.png', width=800)
For example we are provided with the input image with known location of an object (face marked with a rectangle) as shown below.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\digital-images-week4_quizzes-frame_1_with_block.jpg', width=800)
Now we are provided with another image which is the next frame extracted from the same video but with the face unmarked) as shown below. The problem is that we have to locate the face in this next frame and mark it using simple block matching technique (and thereby estimate the motion).
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\digital-images-week4_quizzes-frame_2.jpg', width=800)
As shown below, using just the simple block matching, we can mark the face in the very next frame.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\digital-images-week4_quizzes-frame_2_with_block.jpg', width=800)
Now let's play with the following two videos. The first one is the video of some students working on a university corridor, as shown below (obtained from youtube), extract some consecutive frames, mark a face in one image and use that image to mark all thew faces om the remaining frames that are consecutive to each other, thereby mark the enntire video and estimatethe motion using the simple block matching technique only.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\Week4\\motion_example\\in.gif')
The following figure shows the frame with the face marked, now we shall use this image and block matching technique to estimate the motion of the student in the video, by marking his face in all the consecutive frames and reconstructing the video, as shown below.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\Week4\\motion_example\\out\\block_001.png', width=800)
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\Week4\\motion_example\\out\\out.gif')
The second video is the video of the Google CEO talking, as shown below (obtained from youtube), again extract some consecutive frames, mark his face in one image and use that image to mark all thew faces om the remaining frames that are consecutive to each other, thereby mark the enntire video and estimatethe motion using the simple block matching technique only.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\Week4\\pichai\\in.gif')
The following figure shows the frame with the face marked, now we shall use this image and block matching technique to estimate the motion of the Googel CEO in the video, by marking his face in all the consecutive frames and reconstructing the video, as shown below.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\Week4\\pichai\\out\\block_001.png', width=800)
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\Week4\\pichai\\out\\out.gif')
The most interesting thing above is that we did not use any sophisticated image features such as HOG, SIFT, still it did a pretty descent job with simple block matching.
The following figure describes the problem:
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\ex4.png', width=800)
The following figure shows the original image, the noisy image and images obtained after applying the median filter** of different sizes (nxn, for different values of n*):
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\im4.png')
As can be seen from the following figure, the optimal median filter size is 5x5, which generates the highest quality output, when compared to the original image.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\im5.png')
The following figure shows the description of the problem:
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\ex5.png', width=800)
The following figures show the theory behind the inverse filters in the (frequency) spectral domain.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\im6.png')
The following are the steps for the images with motion blurs using the Inverse Filter:
The following figures show the inverse filter is applied with different threshold value T (starting from 0.1 to 0.9 in that order) to restore the noisy / blurred image.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\inverse_filter_0.1.png')
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\inverse_filter_0.2.png')
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\inverse_filter_0.3.png')
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\inverse_filter_0.4.png')
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\inverse_filter_0.5.png')
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\inverse_filter_0.6.png')
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\inverse_filter_0.7.png')
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\inverse_filter_0.8.png')
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\inverse_filter_0.9.png')
The following figure shows how the Restored PSNR and the ISNR varies with different values if T.
Image(filename='C:\\courses\\coursera\\Past\\Image Processing & CV\\NorthWestern - Image Processing\\im8.png')